# coding=utf-8
"""
Author: Mr.夏末
@Function: 参数支持url，JSON。字典
"""
# url格式参数
import json

s = "username=Will' or 1=1 #&password=123456&987654"

params_dict = {}
# 切割键值对
params = s.split('&')
print(params)

for p in params:
    i = p.find('=')
    if i > 0:
        params_dict[p[:i]] = p[i+1:]
    else:
        params_dict[p] = None

print(params_dict)

# 字典格式
s = "{'username': 'hzs02', 'password': '123456','t':None}"
# s = '1+1'
# eval是把符合python语法的代码执行，得到结果
s = eval(s)
print(s)
print(type(s))

# json格式
s = '{"username": "hzs02", "password": "123456","m":true}'
print(json.loads(s))
